﻿using SpecialEffects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Threading;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GlobalGameClasses;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Xna.Framework.Audio;

namespace SirianTestEnvironment
{
    
    
    /// <summary>
    ///Dies ist eine Testklasse für "BasicFireAndSmokeTest" und soll
    ///alle BasicFireAndSmokeTest Komponententests enthalten.
    ///</summary>
    [TestClass()]
    public class BasicFireAndSmokeTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Ruft den Testkontext auf, der Informationen
        ///über und Funktionalität für den aktuellen Testlauf bietet, oder legt diesen fest.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Zusätzliche Testattribute
        /// <summary>
        /// Initializes the required attributes for the test methods of this test class.
        /// </summary>
        /// <param name="testContext"></param>
        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.Visible = false;
            form.ShowInTaskbar = false;
            PresentationParameters param = new PresentationParameters();
            param.DeviceWindowHandle = form.Handle;
            param.IsFullScreen = false;
            GraphicsDevice device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, param);

            Texture2D fireTex;
            string filePath1 = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\Out\\fire.png";
            System.IO.FileStream fs1 = new System.IO.FileStream(filePath1, System.IO.FileMode.Open);
            fireTex = Texture2D.FromStream(device, fs1);

            Texture2D smokeTex;
            string filePath2 = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\Out\\smoke.png";
            System.IO.FileStream fs2 = new System.IO.FileStream(filePath2, System.IO.FileMode.Open);
            smokeTex = Texture2D.FromStream(device, fs2);

            TimeSpan totalGameTime = new TimeSpan(0, 0, 0, 0, 5000);
            TimeSpan elapsedGameTime = new TimeSpan(0, 0, 0, 0, 100);
            GameTime gameTime = new GameTime(totalGameTime, elapsedGameTime);
            GlobalGameValues.Values.content.Textures.Clear();
            GlobalGameValues.Values.graphicsDevice = device;
            GlobalGameValues.Values.content.addTexture("smokeTexture", smokeTex);
            GlobalGameValues.Values.content.addTexture("fireTexture", fireTex);
            GlobalGameValues.Values.gameTime = gameTime;

            fs1.Close();
            fs2.Close();

        }
        
        #endregion



        /// <summary>
        ///Test for "AddParticle"
        ///</summary>
        [TestMethod()]
        public void AddParticleTest()
        {
            BasicFireAndSmoke testFireTrail = BasicFireAndSmoke.CreateFireTrail_PlayerShip();
            var fireTrail = new PrivateObject(testFireTrail);

            object[] args = new object[2];
            args[0] = new Vector3(1, 2, 3);
            args[1] = new Vector3(4, 5, 6);

            ParticleVertex[] testParticles = (ParticleVertex[])fireTrail.GetProperty("particles");

            Assert.AreEqual(0, (int)fireTrail.GetProperty("nActive"));
            Assert.AreEqual(Vector3.Zero, testParticles[0].startPos);
            Assert.AreEqual(Vector3.Zero, testParticles[1].startPos);
            Assert.AreEqual(Vector3.Zero, testParticles[2].startPos);
            Assert.AreEqual(Vector3.Zero, testParticles[3].startPos);
            Assert.AreEqual(Vector3.Zero, testParticles[0].direction);
            Assert.AreEqual(Vector3.Zero, testParticles[1].direction);
            Assert.AreEqual(Vector3.Zero, testParticles[2].direction);
            Assert.AreEqual(Vector3.Zero, testParticles[3].direction);
            Assert.AreEqual(0, testParticles[0].speed);
            Assert.AreEqual(0, testParticles[1].speed);
            Assert.AreEqual(0, testParticles[2].speed);
            Assert.AreEqual(0, testParticles[3].speed);
            Assert.IsFalse(testParticles[0].birthTime >= 0);
            Assert.IsFalse(testParticles[1].birthTime >= 0);
            Assert.IsFalse(testParticles[2].birthTime >= 0);
            Assert.IsFalse(testParticles[3].birthTime >= 0);

            fireTrail.Invoke("AddParticle", args);
            
            Assert.AreEqual(4, (int)fireTrail.GetProperty("nActive"));
            Assert.AreNotEqual(Vector3.Zero, testParticles[0].startPos);
            Assert.AreNotEqual(Vector3.Zero, testParticles[1].startPos);
            Assert.AreNotEqual(Vector3.Zero, testParticles[2].startPos);
            Assert.AreNotEqual(Vector3.Zero, testParticles[3].startPos);
            Assert.AreNotEqual(Vector3.Zero, testParticles[0].direction);
            Assert.AreNotEqual(Vector3.Zero, testParticles[1].direction);
            Assert.AreNotEqual(Vector3.Zero, testParticles[2].direction);
            Assert.AreNotEqual(Vector3.Zero, testParticles[3].direction);
            Assert.AreNotEqual(0, testParticles[0].speed);
            Assert.AreNotEqual(0, testParticles[1].speed);
            Assert.AreNotEqual(0, testParticles[2].speed);
            Assert.AreNotEqual(0, testParticles[3].speed);
            Assert.IsTrue(testParticles[0].birthTime >= 0);
            Assert.IsTrue(testParticles[1].birthTime >= 0);
            Assert.IsTrue(testParticles[2].birthTime >= 0);
            Assert.IsTrue(testParticles[3].birthTime >= 0);

        }

        /// <summary>
        ///Test for "CloneTrail"
        ///</summary>
        [TestMethod()]
        public void CloneTrailTest()
        {
            BasicFireAndSmoke originalTrail = BasicFireAndSmoke.CreateSmokeTrail_Missile();
            BasicFireAndSmoke testCloneTrail = originalTrail.CloneTrail();
            var cloneTrail = new PrivateObject(testCloneTrail);

            Assert.AreEqual(600, (int)cloneTrail.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(3), (Vector2)cloneTrail.GetProperty("particleSize"));
            Assert.AreEqual(300, (float)cloneTrail.GetProperty("maxTime"));
            Assert.AreEqual(Vector3.Zero, (Vector3)cloneTrail.GetProperty("wind"));
            Assert.AreEqual(0, (float)cloneTrail.GetProperty("fadeInTime"));
            Assert.AreEqual(1, (float)cloneTrail.GetProperty("area"));
            Assert.AreEqual(0, (float)cloneTrail.GetProperty("spreadAngle"));
            Assert.AreEqual(50, (float)cloneTrail.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)cloneTrail.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)cloneTrail.GetProperty("texture"));
            Assert.IsFalse((bool)cloneTrail.GetProperty("hasFinished"));

        }

        /// <summary>
        ///Test for "CreateFireTrail_PlayerShip"
        ///</summary>
        [TestMethod()]
        public void CreateFireTrail_PlayerShipTest()
        {
            BasicFireAndSmoke testFireTrail = BasicFireAndSmoke.CreateFireTrail_PlayerShip();

            var fireTrail = new PrivateObject(testFireTrail);

            Assert.AreEqual(800, (int)fireTrail.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(10), (Vector2)fireTrail.GetProperty("particleSize"));
            Assert.AreEqual(150, (float)fireTrail.GetProperty("maxTime"));
            Assert.AreEqual(Vector3.Zero, (Vector3)fireTrail.GetProperty("wind"));
            Assert.AreEqual(0, (float)fireTrail.GetProperty("fadeInTime"));
            Assert.AreEqual(1, (float)fireTrail.GetProperty("area"));
            Assert.AreEqual(0, (float)fireTrail.GetProperty("spreadAngle"));
            Assert.AreEqual(150, (float)fireTrail.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)fireTrail.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)fireTrail.GetProperty("texture"));
            Assert.IsFalse((bool)fireTrail.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateParticleVertices"
        ///</summary>
        [TestMethod()]
        [DeploymentItem("SirianGame.exe")]
        public void CreateParticleVerticesTest()
        {
            BasicFireAndSmoke testFireTrail = BasicFireAndSmoke.CreateFireTrail_PlayerShip();

            var fireTrail = new PrivateObject(testFireTrail);

            fireTrail.Invoke("CreateParticleVertices", null);

            ParticleVertex[] particles = (ParticleVertex[])fireTrail.GetProperty("particles");
            int[] indices = (int[])fireTrail.GetProperty("indices");
            int particleCount = (int)fireTrail.GetProperty("particleCount");

            Assert.IsNotNull(indices);
            Assert.IsNotNull(particles);
            Assert.IsTrue(indices.Length == particleCount * 6);
            Assert.IsTrue(particles.Length == particleCount * 4);

            int x = 0;
            for (int i = 0; i < particleCount * 4; i += 4)
            {
                Assert.AreEqual(Vector3.Zero, particles[i + 0].startPos);
                Assert.AreEqual(new Vector2(0, 0), particles[i + 0].uv);
                Assert.AreEqual(Vector3.Zero, particles[i + 0].direction);
                Assert.AreEqual(0, particles[i + 0].speed);
                Assert.AreEqual(-(float)fireTrail.GetProperty("maxTime"), particles[i + 0].birthTime);

                Assert.AreEqual(Vector3.Zero, particles[i + 1].startPos);
                Assert.AreEqual(new Vector2(0, 1), particles[i + 1].uv);
                Assert.AreEqual(Vector3.Zero, particles[i + 1].direction);
                Assert.AreEqual(0, particles[i + 1].speed);
                Assert.AreEqual(-(float)fireTrail.GetProperty("maxTime"), particles[i + 1].birthTime);

                Assert.AreEqual(Vector3.Zero, particles[i + 2].startPos);
                Assert.AreEqual(new Vector2(1, 1), particles[i + 2].uv);
                Assert.AreEqual(Vector3.Zero, particles[i + 2].direction);
                Assert.AreEqual(0, particles[i + 2].speed);
                Assert.AreEqual(-(float)fireTrail.GetProperty("maxTime"), particles[i + 2].birthTime);

                Assert.AreEqual(Vector3.Zero, particles[i + 3].startPos);
                Assert.AreEqual(new Vector2(1, 0), particles[i + 3].uv);
                Assert.AreEqual(Vector3.Zero, particles[i + 3].direction);
                Assert.AreEqual(0, particles[i + 3].speed);
                Assert.AreEqual(-(float)fireTrail.GetProperty("maxTime"), particles[i + 3].birthTime);
                
                Assert.AreEqual(i + 0, indices[x++]);
                Assert.AreEqual(i + 3, indices[x++]);
                Assert.AreEqual(i + 2, indices[x++]);
                Assert.AreEqual(i + 2, indices[x++]);
                Assert.AreEqual(i + 1, indices[x++]);
                Assert.AreEqual(i + 0, indices[x++]);
            }
        }

        /// <summary>
        ///Test for "CreateSmokeLevel1_Boss"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel1_BossTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel1_Boss();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(400, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(200, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(5, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(1, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(10, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel1_Player"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel1_PlayerTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel1_Player();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(300, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(200, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(5, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(1, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(10, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel2_Boss"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel2_BossTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel2_Boss();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(500, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(300, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(10, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(5, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(20, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel2_Player"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel2_PlayerTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel2_Player();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(400, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(300, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(10, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(5, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(20, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel3_Boss"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel3_BossTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel3_Boss();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(600, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(400, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(20, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(10, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(30, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel3_Player"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel3_PlayerTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel3_Player();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(500, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(400, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(15, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(10, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(30, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel4_Boss"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel4_BossTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel4_Boss();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(700, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(500, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(25, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(15, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(40, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel4_Player"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel4_PlayerTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel4_Player();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(600, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(500, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(20, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(15, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(40, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel5_Boss"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel5_BossTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel5_Boss();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(800, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(600, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(30, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(20, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(50, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeLevel5_Player"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeLevel5_PlayerTest()
        {
            BasicFireAndSmoke testDamageSmoke = BasicFireAndSmoke.CreateSmokeLevel5_Player();
            var damageSmoke = new PrivateObject(testDamageSmoke);

            Assert.AreEqual(700, (int)damageSmoke.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(25), (Vector2)damageSmoke.GetProperty("particleSize"));
            Assert.AreEqual(600, (float)damageSmoke.GetProperty("maxTime"));
            Assert.AreEqual(new Vector3(10, 0, 0), (Vector3)damageSmoke.GetProperty("wind"));
            Assert.AreEqual(0, (float)damageSmoke.GetProperty("fadeInTime"));
            Assert.AreEqual(25, (float)damageSmoke.GetProperty("area"));
            Assert.AreEqual(20, (float)damageSmoke.GetProperty("spreadAngle"));
            Assert.AreEqual(50, (float)damageSmoke.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)damageSmoke.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)damageSmoke.GetProperty("texture"));
            Assert.IsFalse((bool)damageSmoke.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeTrail_Missile"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeTrail_MissileTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_Missile();

            var smokeTrail = new PrivateObject(testSmokeTrail);

            Assert.AreEqual(600, (int)smokeTrail.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(3), (Vector2)smokeTrail.GetProperty("particleSize"));
            Assert.AreEqual(300, (float)smokeTrail.GetProperty("maxTime"));
            Assert.AreEqual(Vector3.Zero, (Vector3)smokeTrail.GetProperty("wind"));
            Assert.AreEqual(0, (float)smokeTrail.GetProperty("fadeInTime"));
            Assert.AreEqual(1, (float)smokeTrail.GetProperty("area"));
            Assert.AreEqual(0, (float)smokeTrail.GetProperty("spreadAngle"));
            Assert.AreEqual(50, (float)smokeTrail.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)smokeTrail.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)smokeTrail.GetProperty("texture"));
            Assert.IsFalse((bool)smokeTrail.GetProperty("hasFinished"));
            
        }

        /// <summary>
        ///Test for "CreateSmokeTrail_PlayerShip"
        ///</summary>
        [TestMethod()]
        public void CreateSmokeTrail_PlayerShipTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_PlayerShip();

            var smokeTrail = new PrivateObject(testSmokeTrail);

            Assert.AreEqual(800, (int)smokeTrail.GetProperty("particleCount"));
            Assert.AreEqual(new Vector2(10), (Vector2)smokeTrail.GetProperty("particleSize"));
            Assert.AreEqual(350, (float)smokeTrail.GetProperty("maxTime"));
            Assert.AreEqual(Vector3.Zero, (Vector3)smokeTrail.GetProperty("wind"));
            Assert.AreEqual(10, (float)smokeTrail.GetProperty("fadeInTime"));
            Assert.AreEqual(1, (float)smokeTrail.GetProperty("area"));
            Assert.AreEqual(0, (float)smokeTrail.GetProperty("spreadAngle"));
            Assert.AreEqual(150, (float)smokeTrail.GetProperty("maxSpeed"));
            Assert.IsNotNull((Random)smokeTrail.GetProperty("rand"));
            Assert.IsNotNull((Texture2D)smokeTrail.GetProperty("texture"));
            Assert.IsFalse((bool)smokeTrail.GetProperty("hasFinished"));
            
            
        }


        /// <summary>
        ///Test for "HasFinished"
        ///</summary>
        [TestMethod()]
        public void HasFinishedTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_PlayerShip();

            var smokeTrail = new PrivateObject(testSmokeTrail);

            Assert.IsFalse((bool)smokeTrail.GetProperty("hasFinished"));
            Assert.IsFalse((bool)smokeTrail.Invoke("HasFinished", null));

            smokeTrail.SetProperty("hasFinished", true);

            Assert.IsTrue((bool)smokeTrail.GetProperty("hasFinished"));
            Assert.IsTrue((bool)smokeTrail.Invoke("HasFinished", null));

        }

        /// <summary>
        ///Test for "OffsetIndex"
        ///</summary>
        [TestMethod()]
        [DeploymentItem("SirianGame.exe")]
        public void OffsetIndexTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_PlayerShip();

            var smokeTrail = new PrivateObject(testSmokeTrail);

            int start = 0;
            int count = 10;

            object[] args = new object[2];
            args[0] = start;
            args[1] = count;

            int offset = (int)smokeTrail.Invoke("OffsetIndex", args);

            Assert.AreEqual(10, offset);

            ParticleVertex[] particles = (ParticleVertex[])smokeTrail.GetProperty("particles");
            int particleCount = particles.Length;
            int test_count = particleCount - 3;

            args[0] = test_count;

            offset = (int)smokeTrail.Invoke("OffsetIndex", args);

            Assert.AreEqual(7, offset);

        }

        /// <summary>
        ///Test for "RandVec"
        ///</summary>
        [TestMethod()]
        [DeploymentItem("SirianGame.exe")]
        public void RandVecTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_PlayerShip();

            var smokeTrail = new PrivateObject(testSmokeTrail);

            Vector3 min = new Vector3(1, 2, 3);
            Vector3 max = new Vector3(4, 5, 6);
            object[] args = new object[2];
            args[0] = min;
            args[1] = max;

            Vector3 randVector = (Vector3)smokeTrail.Invoke("RandVec", args);

            Assert.IsTrue(randVector.X >= min.X);
            Assert.IsTrue(randVector.Y >= min.Y);
            Assert.IsTrue(randVector.Z >= min.Z);
            Assert.IsTrue(randVector.X <= max.X);
            Assert.IsTrue(randVector.Y <= max.Y);
            Assert.IsTrue(randVector.Z <= max.Z);

            max = new Vector3(1, 2, 3);
            args[1] = max;

            randVector = (Vector3)smokeTrail.Invoke("RandVec", args);

            Assert.IsTrue(randVector.X == min.X);
            Assert.IsTrue(randVector.Y == min.Y);
            Assert.IsTrue(randVector.Z == min.Z);
            

        }

        /// <summary>
        ///Test for "SetDirection"
        ///</summary>
        [TestMethod()]
        public void SetDirectionTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_PlayerShip();

            var smokeTrail = new PrivateObject(testSmokeTrail);

            Assert.AreEqual(Vector3.Zero, (Vector3)smokeTrail.GetProperty("movingDirection"));

            Vector3 newMovingDirection = Vector3.Normalize(new Vector3(1.01f, 2.01f, 3.01f));
            object[] args = new object[1];
            args[0] = newMovingDirection;

            smokeTrail.Invoke("SetDirection", args);

            Assert.AreEqual(newMovingDirection, (Vector3)smokeTrail.GetProperty("movingDirection"));    
        }

        /// <summary>
        ///Test for "SetPosition"
        ///</summary>
        [TestMethod()]
        public void SetPositionTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_PlayerShip();

            var smokeTrail = new PrivateObject(testSmokeTrail);

            Assert.AreEqual(Vector3.Zero, (Vector3)smokeTrail.GetProperty("startPos"));    
            
            Vector3 newStartPosition = new Vector3(10, 10, 10);
            object[] args = new object[1];
            args[0] = newStartPosition;

            smokeTrail.Invoke("SetPosition", args);

            Assert.AreEqual(newStartPosition, (Vector3)smokeTrail.GetProperty("startPos"));    
        }

        /// <summary>
        ///Test for "Update"
        ///</summary>
        [TestMethod()]
        public void UpdateTest()
        {
            BasicFireAndSmoke testSmokeTrail = BasicFireAndSmoke.CreateSmokeTrail_PlayerShip();
            var smokeTrail = new PrivateObject(testSmokeTrail);

            Assert.AreEqual(0, (int)smokeTrail.GetProperty("nActive"));
            Assert.AreEqual(0, (int)smokeTrail.GetProperty("activeStart"));

            //Adding four particles
            smokeTrail.Invoke("Update", null);
            Assert.AreEqual(4, (int)smokeTrail.GetProperty("nActive"));

            TimeSpan totalGameTime = new TimeSpan(0, 0, 0, 0, 5001 + (int)(float)smokeTrail.GetProperty("maxTime"));
            TimeSpan elapsedGameTime = new TimeSpan(0, 0, 0, 0, 500);
            GameTime gameTime = new GameTime(totalGameTime, elapsedGameTime);
            GlobalGameValues.Values.gameTime = gameTime;

            //Adding the next four particles. The first four particles are inactive now. 
            smokeTrail.Invoke("Update", null);
            Assert.AreEqual(4, (int)smokeTrail.GetProperty("activeStart"));
            Assert.AreEqual(4, (int)smokeTrail.GetProperty("nActive"));

            //Adding the next four particles.
            smokeTrail.Invoke("Update", null);
            Assert.AreEqual(4, (int)smokeTrail.GetProperty("activeStart"));
            Assert.AreEqual(8, (int)smokeTrail.GetProperty("nActive"));

        }
    }
}
